package jinyilw.swing.rlaf.theme;

import jinyilw.swing.rlaf.UISettable;
import jinyilw.swing.rlaf.UITools;

import javax.swing.plaf.ColorUIResource;
import java.awt.Color;

public class RColorSet implements UISettable
{
	public static final Color white = new ColorUIResource(255, 255, 255);
	public static final Color lightGray = new ColorUIResource(192, 192, 192);
	public static final Color gray = new ColorUIResource(128, 128, 128);
	public static final Color darkGray = new ColorUIResource(64, 64, 64);
	public static final Color lightBGColor = new ColorUIResource(230, 255, 255);
	public static final Color blackBGColor = new ColorUIResource(25, 25, 25);

	public static final Color lightColor = new Color(160, 160, 160);

	static Color lightTextColor, blackTextColor;
	static Color lightUnableTextColor, darkUnableTextColor,
			blackUnableTextColor;
	static Color lightUnSelectFTColor, blackUnSelectFTColor;
	static Color lightTBGColor, darkTBGColor, blackTBGColor,
			lightScrollBarColor;
	public static Color lightTransBGColor, darkTransBGColor, blackTransBGColor;
	public static Color lightBorderColor, darkBorderColor, blackBorderColor;
	static Color lightShadowColor, darkShadowColor, blackShadowColor;
	static Color lightLineColor;

	static volatile RColorSet colorSet;

	public Color textColor, unableTextColor;
	public Color transTBGColor, unSelectFTColor;
	public Color transBGColor, bgColor;
	public Color lineColor, borderColor;
	public Color shadowColor;
	public Color scrollBarColor;
	public Color iconColor;

	private RColorSet()
	{
		lightTextColor = new ColorUIResource(20, 20, 20);
		blackTextColor = new ColorUIResource(230, 230, 230);

		lightUnableTextColor = new Color(64, 64, 64, 150);
		darkUnableTextColor = new Color(160, 160, 160);
		blackUnableTextColor = new Color(128, 128, 128, 150);

		lightUnSelectFTColor = new Color(90, 90, 90);
		blackUnSelectFTColor = new Color(170, 170, 170);

		lightTransBGColor = new Color(230, 255, 255, 150);
		darkTransBGColor = new Color(90, 90, 90, 150);
		blackTransBGColor = new Color(45, 45, 45, 150);

		lightTBGColor = new Color(230, 255, 255, 130);
		darkTBGColor = new Color(128, 128, 128, 120);
		blackTBGColor = new Color(64, 64, 64, 150);

		lightScrollBarColor = new Color(255, 255, 255, 180);

		lightBorderColor = new Color(100, 100, 100, 180);
		darkBorderColor = new Color(192, 192, 192, 180);
		blackBorderColor = new Color(180, 180, 180, 180);

		lightShadowColor = new Color(100, 100, 100, 210);
		darkShadowColor = new Color(50, 50, 50, 190);
		blackShadowColor = new Color(100, 100, 100, 180);

		lightLineColor = new Color(60, 60, 60, 200);

		UITools.installUITheme(this);
	}

	public static RColorSet getColorSet()
	{
		if (colorSet == null)
			synchronized (RColorSet.class)
			{
				if (colorSet == null)
					colorSet = new RColorSet();
			}
		return colorSet;
	}

	@Override
	public void lightTheme()
	{
		transBGColor = lightTransBGColor;
		bgColor = lightBGColor;
		textColor = lightTextColor;
		unableTextColor = lightUnableTextColor;
		transTBGColor = lightTBGColor;
		scrollBarColor = lightScrollBarColor;
		unSelectFTColor = lightUnSelectFTColor;
		lineColor = lightLineColor;
		iconColor = borderColor = lightBorderColor;
		shadowColor = lightShadowColor;
		DoubleColor.DARK = false;
	}

	@Override
	public void darkTheme()
	{
		transBGColor = darkTransBGColor;
		bgColor = darkGray;
		textColor = white;
		unableTextColor = darkUnableTextColor;
		scrollBarColor = transTBGColor = darkTBGColor;
		unSelectFTColor = blackTextColor;
		lineColor = lightGray;
		borderColor = darkBorderColor;
		shadowColor = darkShadowColor;
		iconColor = lightScrollBarColor;
		DoubleColor.DARK = true;
	}

	@Override
	public void blackTheme()
	{
		transBGColor = blackTransBGColor;
		bgColor = blackBGColor;
		textColor = blackTextColor;
		unableTextColor = blackUnableTextColor;
		scrollBarColor = transTBGColor = blackTBGColor;
		unSelectFTColor = blackUnSelectFTColor;
		lineColor = lightGray;
		borderColor = blackBorderColor;
		shadowColor = blackShadowColor;
		iconColor = lightScrollBarColor;
		DoubleColor.DARK = true;
	}
}
